package org.popupcommunication.controller;

import org.popupcommunication.model.User;
import org.popupcommunication.service.UserManager;
import org.popupcommunication.web.UserFormAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AdminController {
	@Autowired UserManager userService;	

	@RequestMapping(value={"/admin"})
	public String showIndex (Model model) {
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	    String name = auth.getName();
	    User toto = userService.findByEmail(name);
	    model.addAttribute("utilisateur", toto);
	    model.addAttribute("Lionel", "lionel");
//	logger.info("Return Index View");
	return "admin/index";
	}
}
